<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>账户管理</title>
<link rel="stylesheet" href="../../easyui/themes/default/easyui.css"
	type="text/css" media="screen" />
<link rel="stylesheet" href="../../easyui/themes/icon.css"
	type="text/css" media="screen" />
<link rel="stylesheet" href="../../css/main.css" type="text/css"
	media="screen" />
<link rel="stylesheet" type="text/css" href="../../css/Tooltip.css" />
<script src="../../easyui/jquery-1.4.4.min.js"></script>
<script src="../../easyui/jquery.easyui.min.js"></script>
<!-- mytab -->
<script src="../../myjs/myTab.js"></script>
<!-- sys -->
<script src="../../myjs/sys.js"></script>
<script src="../../easyui/easyMask.js"></script>
<script src="../../easyui/easyUI.js"></script>
<script src="../../easyui/easyLayer.js"></script>
<script src="../../myjs/accountManager.js"></script>


<script>
var greyLayer ;
var getUrlForUser='/pxglxt/user_list/getLabours';
var getTextForUser='real_name';
		$(function(){
			grid = $('#tt').datagrid({
				url:'/pxglxt/user_list/getUsers',
				pagination:true,
				singleSelect:true,
				fit:true,//表格自动填充
				loadMsg:'正在努力为您加载，请稍作等待…',//加载信息
				toolbar:[{
					text:'新增',
					iconCls:'icon-add',
					handler:'newAccount'
				},'-',{
					text:'修改',
					iconCls:'icon-edit',
					handler:'editAccount'
					
				},'-',{
					text:'删除',
					iconCls:'icon-remove',
					handler:'delAccount'
				}]
			});
			//初始化pagination工具开始
			var pagetool = $('#tt').datagrid('getPager');
			pagetool.pagination({				
					beforePageText:'第',
					afterPageText:'页，共{pages}页',
					displayMsg:'显示从 {from} 到  {to} , 总记录 {total} '});
			//初始化pagination工具结束
						
			$('body').layout();
			$('#btn-save,#btn-cancel').linkbutton();
			win = $('#user-window').window({
				collapsible:false,
				minimizable:false, 
				maximizable:true, 
				closable:true,
				onClose:function(){greyLayer.close();},
				closed:true
			});
			form = win.find('form');

			//if($('password').value != $('passwordConfirm')){
				//$('errtip').value ='密码不一致,请确认!';
			//}
			greyLayer = new easyMask(null,'100%','100%',100,'#000',8,true);
		});

		function getUser(ut){
			if(ut=='员工'){
				getUrlForUser='/pxglxt/user_list/getLabours';
				getTextForUser='real_name';
			}
			if(ut=='教师'){
				getUrlForUser='/pxglxt/user_list/getTeachers';
				getTextForUser='tea_real_name';
			}
			if(ut=='学员'){
				getUrlForUser='/pxglxt/user_list/getStudents';
				getTextForUser='stu_name';
			}
			$('#userinfo_id').combobox({
			    url:getUrlForUser,
			    valueField:'id',
			    textField:getTextForUser
			});
						
		}
	</script>
</head>
<body>
<div region="center" fit="true" style="padding: 5px;">
<table id="tt">
	<thead>
		<tr>
			<th field="username" width="100%">账户名称</th>
			<th field="password" width="100%">密码</th>
			<th field="priv_name" width="100%">角色</th>
			<th field="userinfo_name" width="100%">用户ID</th>
			<th field="user_type" width="100%">用户类型</th>
		</tr>
	</thead>
</table>
</div>
<div id="user-window" title="账户管理窗口"
	style="width: 400px; height: 320px;">
<div style="padding: 20px 20px 40px 80px;">

<form method="post">
<table>
	<tr>
		<td>用户身份：</td>
		<td><select id="user_type" name="user_type"  style="width: 140px; height: 22px; font-size: 15px;" onchange="getUser(this.options[this.selectedIndex].value);">
			<option value="员工" selected>员工</option>
			<option value="教师">教师</option>
			<option value="学员">学员</option>
		</select></td>
	</tr>
	<tr>
		<td>用户ID：</td>
		<td><input id="userinfo_id" name="userinfo_id" type="text" class="easyui-validatebox"
			required="true"></input></td>
	</tr>
	<tr>
		<td>账户名称：</td>
		<td><input name="username" type="text" class="easyui-validatebox"
			required="true"></input></td>
	</tr>
	<tr>
		<td>密码：</td>
		<td><input name="password" type="password"
			class="easyui-validatebox" required="true"></input></td>
	</tr>
	<tr>
		<td>角色：</td>
		<td><input class="easyui-combobox" name="priv_id"
			url="/pxglxt/user_list/getSys_privs" valueField="id"
			textField="priv_name" multiple="false" panelHeight="auto"
			required="true"></input></td>
	</tr>
</table>
</form>

</div>
<div style="text-align: center; padding: 5px;"><a
	href="javascript:void(0)" onclick="saveAccount()" id="btn-save"
	icon="icon-save">确定</a> <a href="javascript:void(0)"
	onclick="closeWindow()" id="btn-cancel" icon="icon-cancel">取消</a></div>
</div>
</body>
</html>
